import java.io.*;
import java.sql.*;


public class testdb {
	public static void main(String[] args) throws Exception {
		trans t = new trans();
		Connection con = t.getConnection();
		Statement stmt= con.createStatement();
		try{
            /* num is the number of transaction completed; 
             * ibal is the total ibalance in acct table;
             * bal is the total balance in acct table;
             * amount is the total amount in trans table; 
             */
			int num=0,ibal=0, bal=0, amount=0;
			ResultSet res = stmt.executeQuery("SELECT * FROM ticket ");
			res.next();
			num = res.getInt(1);
	  	    System.out.print("Number of Transactions are :"+num+"\n");
	  	    
	  	    
	  	    res = stmt.executeQuery("SELECT * FROM acct ");	  	    
	  	    while (res.next()){
	  	    	ibal += res.getInt(2);
	  	    	bal  +=res.getInt(3);
	  	    }
	  	    System.out.print("ibal = "+ibal+" ; bal = "+ bal+"\n");
	  	    
	  	    if(num!=0){
	  	    res = stmt.executeQuery("SELECT * FROM trans ");
	  	    while (res.next()){
	  	    	amount += res.getInt(4);
	  	    }
	  	    }
	  	    System.out.print("amount = "+amount+" balance-amount = "+(bal-amount));
			}//end try
			  catch (Exception e){
				System.out.print(e);
			}
		
	}

}
